#pragma once

#include "footage.h"

namespace icache {

class coordinator;

class deinterlaced_item_id;
typedef boost::shared_ptr<deinterlaced_item_id> deinterlaced_item_id_sptr;

/// deinterlaced_footage is any live footage each frame of which is divided on two

class deinterlaced_footage : public footage
{
public: //footage inerface
	virtual string filepath() const;
	virtual item_id_sptr frame_id(int frame);
	virtual cached_image_sptr get(int frame, nearby may_be_requested_later = no_nearby, bool wait = true);
	virtual cached_image_sptr try_get(int frame);
	virtual icache::cache * cache() const;
	virtual xml::stream & serialize(xml::stream & s, string const & reference_path);
	virtual string description() const;
	virtual int size() const;
	virtual int first_frame_num() const;
	virtual size_extent dim() const;
	virtual bool alpha_channel() const;
	virtual void set_deinterlace_fields(deinterlace_fields value);
	virtual deinterlace_fields get_deinterlace_fields() const;
	virtual void set_deinterlace_method(deinterlace_method value);
	virtual deinterlace_method get_deinterlace_method() const;
	virtual fraction fps() const;
public:
	deinterlaced_footage(footage_sptr const & supplier);
	deinterlaced_footage(footage_sptr const & supplier, deinterlace_fields f, deinterlace_method m);
	virtual ~deinterlaced_footage();
	/// if the method is 'Off' then returns the supplier, otherwise creates new deinterlaced_footage
	static footage_sptr create(
		deinterlace_fields field, deinterlace_method method,
		footage_sptr const & supplier);
private:
	deinterlaced_item_id_sptr frame_id_core(int frame);
private:
	footage_sptr supplier_;
	deinterlace_fields fields_;
	deinterlace_method method_;
};

} //namespace icache
